package com.seedwill.common.query.schema;

import java.util.ArrayList;
import java.util.List;

/**
 * 组条件元数据
 * 
 * @author kdyi
 *
 */
public class QueryCriteriaGroupSchema {
	
	/**
	 * 子组条件元数据
	 */
	protected List<QueryCriteriaGroupSchema> childrenGroupSchema;
	
	/**
	 * 编号
	 */
	protected String groupSchemaId;
	/**
	 * 名称
	 */
	protected String groupSchemaName;
	
	/**
	 * 条件顺序
	 */
	protected int groupIndex;
	
	/**
	 * 当前查询条件元数据
	 */
	protected List<QueryCriteriaSchema> criteriaSchemaes;
	
	
	public QueryCriteriaGroupSchema() {
		super();
		this.groupIndex = 0;
		
		if(null == criteriaSchemaes){
			criteriaSchemaes = new ArrayList<QueryCriteriaSchema>();
		}
		
		if(null == childrenGroupSchema){
			childrenGroupSchema = new ArrayList<QueryCriteriaGroupSchema>();
		}
	}
	
	public QueryCriteriaGroupSchema(
			String groupSchemaId, String groupSchemaName, int groupIndex,
			List<QueryCriteriaGroupSchema> childrenGroupSchema,
			List<QueryCriteriaSchema> criteriaSchemaes) {
		super();
		this.childrenGroupSchema = childrenGroupSchema;
		this.groupSchemaId = groupSchemaId;
		this.groupSchemaName = groupSchemaName;
		this.groupIndex = groupIndex;
		this.criteriaSchemaes = criteriaSchemaes;
	}
	public QueryCriteriaGroupSchema(String id, int index) {
		super();
		this.groupSchemaId = id;
		this.groupIndex = index;
	}

	public QueryCriteriaGroupSchema(String id) {
		super();
		this.groupSchemaId = id;
		this.groupIndex = 0;
	}
	public QueryCriteriaGroupSchema(String id, String name) {
		super();
		this.groupSchemaId = id;
		this.groupSchemaName = name;
		this.groupIndex = 0;
	}
	public QueryCriteriaGroupSchema(String id, String name, int index) {
		super();
		this.groupSchemaId = id;
		this.groupSchemaName = name;
		this.groupIndex = index;
	}
	 /**
	 * 初始化
	 */
	public void init(boolean initChildren){
		if(null == criteriaSchemaes){
			criteriaSchemaes = new ArrayList<QueryCriteriaSchema>();
		}
		if(initChildren){
			if(null == childrenGroupSchema){
				childrenGroupSchema = new ArrayList<QueryCriteriaGroupSchema>();
			}
		}
	}
	

//	public boolean add(QueryCriteriaSchema obj) {
//		// TODO Auto-generated method stub
//		return criteriaSchemaes.add(obj);
//	}
//
//	public void clear() {
//		criteriaSchemaes.clear();
//	}
 


}
